package com.lagou;

import com.lagou.bean.Resume;
import com.lagou.repository.ResumeRepository;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.List;

@SpringBootApplication
public class MongoRepositoryMain {
    public static void main(String[] args) {
        ApplicationContext  applicationContext = SpringApplication.run(MongoRepositoryMain.class,args);
        ResumeRepository  resumeRepository = applicationContext.getBean(ResumeRepository.class);
        /* System.out.println(resumeRepository.findAll());
        System.out.println(resumeRepository.findByNameEquals("zhangsan"));
        System.out.println(resumeRepository.findByNameAndExpectSalary("zhangsan",25000)); */
        //System.out.println(resumeRepository.findAll());
        List<Resume> all = resumeRepository.findByNameEquals("初始化");
        for (Resume resume: all) {
            System.out.println(resume);
        }
        System.out.println(resumeRepository.count());

        Resume resume = new Resume();
        resume.setName("测试");
        resume.setSalary(1232.21);
        resumeRepository.save(resume);

        System.out.println(resumeRepository.count());
    }
}
